#include<bits/stdc++.h>
using namespace std;
#define N 1000010
#define double long double
#define int long long
int p[N],c[N],nxt[N];
vector<int> f[N];
int t[N];
int V,L;
stack<int> s;
inline int lb(int x){
	return x&(-x);
}
inline void add(int k,int x){
	for(;k<=L;k+=lb(k)){
		t[k]+=x;
	}
}
inline int ask(int x){
	int ans=0;
	for(;x;x-=lb(x)) ans+=t[x];
	return ans;
}
signed main(){
	freopen("detect.in","r",stdin);
	freopen("detect.out","w",stdout);
	ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
	int T;
	cin>>T;
	while(T--){
		int n,m,ans1=0,ans2=0;
		cin>>n>>m>>L>>V;
		while(!s.empty()) s.pop();
		for(int i=0;i<=L+5;i++){
			c[i]=nxt[i]=t[i]=0;
			f[i].clear();
		}
		double d,v,a;
		for(int i=1;i<=n;i++){
			cin>>d>>v>>a;
			if(a<0 && v>V){
				double tmp=(double)(V*V-v*v)/(2*a);
				f[(int)d].push_back(min((long long)(ceil(tmp)+d-1),L));
			}
			else if(a==0 && v>V) f[(int)d].push_back(L);
			else if(a>0){
				if(v>V) f[(int)d].push_back(L);
				else{
					double s=L-d;
					double tmp=(double)(v*v+2ll*s*a);
					if(tmp>V){
						tmp=(double)(V*V-v*v)/(2*a);
						f[(int)(tmp+d+1)].push_back(L);
					}
				}
			}
		}
		for(int i=1;i<=m;i++){
			cin>>p[i];
			c[p[i]]=1;
			nxt[p[i-1]]=p[i];
		}
		nxt[0]=p[1];
		nxt[p[m]]=L+1;
		int tmp=0;
		for(int i=0;i<=L;i++){
			if(f[i].size()){
				for(int j:f[i]){
					if(j>=nxt[tmp]){
						s.push(j);
						add(j,1);
					}
				}
			}
			if(c[i]){
				tmp=i;
				if(ask(nxt[i]-1)-ask(i-1)>0 && s.size()){
					ans1+=s.size();
					ans2++;
					while(!s.empty()){
						add(s.top(),-1);
						s.pop();
					}
				}
			}
		}
		cout<<ans1<<" "<<m-ans2<<"\n";
	}
	return 0;
}